package edu.ucla.cs.typecast.ping;

import java.util.*;

public class ScriptLogUtil {
	public static String readString(Map<String, String> entry, String key, String def) {
		if (entry == null || key == null) {
			throw new IllegalArgumentException();
		}
		
		if (entry.containsKey(key)) {
			return entry.get(key);
		} else {
			return def;
		}
	}
	
	public static int readInt(Map<String, String> entry, String key, int def) {
		String valAsString = readString(entry, key, null);
		
		if (valAsString == null)
			return def;
		
		try {
			return Integer.parseInt(valAsString);
		}
		catch (NumberFormatException e) {
			return def;
		}
	}
}
